import {
  Column,
  CreateDateColumn,
  Entity,
  JoinTable,
  ManyToMany,
  OneToMany,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';
import { MenuManage } from '../../menuManage/entities/menuManage.entity';
import { UserRole } from 'src/modules/user/entities/user-role.entity';

@Entity()
export class RoleManage {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @ManyToMany(() => MenuManage, (menu) => menu.role)
  @JoinTable()
  menus: MenuManage[];

  @OneToMany(() => UserRole, (userRole) => userRole.role, { nullable: true })
  userRoles: UserRole[];

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
